package net.sx.minemodule.mvp.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.annotation.JSONField;
import com.kedll.library.adapter.MultiTypeAdapter;
import com.kedll.library.mvp.BaseModel;

import net.sx.minemodule.mvp.item.OrderItem;

import java.util.List;

/**
 * @author 11470
 */
public class OrderBean extends BaseModel<OrderItem> implements Parcelable {

    /**
     * "statustxt": "交易成功",
     * "status": 4,
     * "tsid": "zBnE0g6xtQRpkcgN25Mfb2hq38MeOAFWJi9E42wF/dxuQAeTTWN6o1zJ5C0d4m/r",
     * "shopname": "南极人",
     * "shopimg": "/upath/2018/12/4/18168553892456ufi.png",
     * "price": 203,
     * "amount": 1,
     * "Logistics": "aaaa"            * 			}]
     */
    @JSONField(alternateNames = {"shopimg"})
    private String storeImgPath;
    @JSONField(alternateNames = {"shopname"})
    private String storeName;
    @JSONField(alternateNames = {"status"})
    private int orderType;
    @JSONField(alternateNames = {"comdiyarry"})
    private List<GoodsBean> goodsBeanList;
    @JSONField(alternateNames = {"amount"})
    private int goodsCount;
    @JSONField(alternateNames = {"price"})
    private String goodsAllMoney;

    private String statustxt;
    private String Logistics;
    private String tsid;


    public OrderBean() {
    }

    @Override
    public String toString() {
        return "OrderBean{" +
                "storeImgPath='" + storeImgPath + '\'' +
                ", storeName='" + storeName + '\'' +
                ", orderType=" + orderType +
                ", goodsBeanList=" + goodsBeanList +
                ", goodsCount=" + goodsCount +
                ", goodsAllMoney=" + goodsAllMoney +
                ", statustxt='" + statustxt + '\'' +
                ", Logistics='" + Logistics + '\'' +
                '}';
    }

    public String getStoreImgPath() {
        return storeImgPath;
    }

    public void setStoreImgPath(String storeImgPath) {
        this.storeImgPath = storeImgPath;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    /**
     * [待支付|0,已支付|1,已发货|2,已签收|3,确认收货|4,发起退款|5,退款成功|6]
     *
     * @return
     */
    public String getOrderType() {
        switch (orderType) {
            case 0:
                return "待支付";
            case 1:
                return "已支付";
            case 2:
                return "已发货";
            case 3:
                return "已签收";
            case 4:
                return "确认收货";
            case 5:
                return "发起退款";
            case 6:
            case 7:
                return "退款成功";
            default:
                return "";
        }
    }

    public void setOrderType(int orderType) {
        this.orderType = orderType;
    }

    public List<GoodsBean> getGoodsBeanList() {
        return goodsBeanList;
    }

    public void setGoodsBeanList(List<GoodsBean> goodsBeanList) {
        this.goodsBeanList = goodsBeanList;
    }

    public String getTsid() {
        return tsid;
    }

    public void setTsid(String tsid) {
        this.tsid = tsid;
    }

    public int getGoodsCount() {
        return goodsCount;
    }

    public void setGoodsCount(int goodsCount) {
        this.goodsCount = goodsCount;
    }

    public String getGoodsAllMoney() {
        return goodsAllMoney;
    }

    public void setGoodsAllMoney(String goodsAllMoney) {
        this.goodsAllMoney = goodsAllMoney;
    }

    public String getStatustxt() {
        return statustxt;
    }

    public void setStatustxt(String statustxt) {
        this.statustxt = statustxt;
    }

    public String getLogistics() {
        return Logistics;
    }

    public void setLogistics(String logistics) {
        Logistics = logistics;
    }

    @Override
    public OrderItem createItem(MultiTypeAdapter adapter) {
        return new OrderItem(this);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.tsid);
        dest.writeString(this.storeImgPath);
        dest.writeString(this.storeName);
        dest.writeInt(this.orderType);
        dest.writeTypedList(this.goodsBeanList);
        dest.writeInt(this.goodsCount);
        dest.writeString(this.goodsAllMoney);
    }


    protected OrderBean(Parcel in) {
        this.tsid = in.readString();
        this.storeImgPath = in.readString();
        this.storeName = in.readString();
        this.orderType = in.readInt();
        this.goodsBeanList = in.createTypedArrayList(GoodsBean.CREATOR);
        this.goodsCount = in.readInt();
        this.goodsAllMoney = in.readString();

    }

    public static final Creator<OrderBean> CREATOR = new Creator<OrderBean>() {
        @Override
        public OrderBean createFromParcel(Parcel source) {
            return new OrderBean(source);
        }

        @Override
        public OrderBean[] newArray(int size) {
            return new OrderBean[size];
        }
    };
}
